<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" scope="request"/>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <link rel="stylesheet" href="<c:url value='/resources/styles/main.css' />" type="text/css"/>
    <script type="text/javascript">
        var contextPath = '${ctx}/';
        function deleteDate(id,qid){
            <%--/admin/survey/deleteSurvey.do?id=${item.id}&qid=${item.questionnaireId}--%>
            if(window.confirm("确定要删除吗？"))
            {
                window.location.href=contextPath+'/admin/survey/deleteSurvey.do?id='+id+"&qid="+qid;
            }

            <%----%>
        }
    </script>
    <title>问题列表</title>
</head>
<body>
<table class="header">
    <tr>
        <td>
            <h1>问题列表</h1>

        </td>
    </tr>
</table>
<table class="pagination" style="padding-left: 70px;">
    <tr>
        <td>
            <a href="<c:url value="/admin/survey/addSurvey.do" />">新建问题</a>
        </td>
        <td>
            <form method="post" action="<c:url value='/admin/survey/listSurvey.do'/>" >
                问卷名称： <select id="qid" name="qid">
                <option value="0">--请选择--</option>
                <c:forEach var='data' items="${questions}">
                    <option value=${data.id} ${data.id==qid? 'selected':''}>${data.title}</option>
                </c:forEach>
            </select>
                <input type="submit" value="搜索"/>
            </form>


        </td>
    </tr>
</table>

<table class="list">
    <tr>
        <th>序号</th>
        <th>题目</th>
        <th>题型</th>
        <th>创建时间</th>
        <th>删除</th>
    </tr>
    <c:choose>
        <c:when test="${totalCount > 0}">
            <c:forEach var="item" items="${results}">
                <tr>
                        <%--<td><input type="checkbox" class="itemId" value="${item.id}" /></td>--%>

                    <td><a href="<c:url value='/admin/survey/viewSurvey.do?id=${item.id}&qid=${item.questionnaireId}'/>">${item.seq}</a></td>

                    <td>
                        <a href="<c:url value='/admin/survey/viewSurvey.do?id=${item.id}&qid=${item.questionnaireId}'/>">${item.title}</a>
                    </td>
                    <td>
                        <c:if test='${item.type=="multiple"}'>多选</c:if>
                        <c:if test='${item.type=="single"}'>单选</c:if>
                        <c:if test='${item.type=="ask"}'>问答</c:if>

                    </td>
                    <td>
                        <fmt:formatDate value="${item.entryDate}" pattern="yyyy-MM-dd" />
                    </td>
                    <td>
                        <%--<a href="<c:url value='/admin/survey/deleteSurvey.do?id=${item.id}&qid=${item.questionnaireId}'/>">删除</a>--%>
                        <a href="#" onclick="deleteDate('${item.id}','${item.questionnaireId}')">删除</a>
                    </td>
                </tr>
            </c:forEach>
        </c:when>
        <c:otherwise>
            <tr>
                <td colspan="17">没有数据</td>
            </tr>
        </c:otherwise>
    </c:choose>

</table>
</body>
</html>